/*     */ package nccloud.pubimpl.riart.pflow;
/*     */ 
/*     */ import java.util.ArrayList;
/*     */ import java.util.Arrays;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import nc.bs.pub.pf.PfUtilTools;
/*     */ import nc.vo.ml.AbstractNCLangRes;
/*     */ import nc.vo.ml.NCLangRes4VoTransl;
/*     */ import nc.vo.pf.change.PfUtilBaseTools;
/*     */ import nc.vo.pub.AggregatedValueObject;
/*     */ import nc.vo.pub.BusinessException;
/*     */ import nc.vo.pub.BusinessRuntimeException;
/*     */ import nc.vo.pub.CircularlyAccessibleValueObject;
/*     */ import nc.vo.pubapp.pflow.PfUserObject;
/*     */ import nc.vo.uap.pf.PFBatchExceptionInfo;
/*     */ import nc.vo.uap.pf.PfProcessBatchRetObject;
/*     */ import nc.vo.wfengine.definition.WorkflowTypeEnum;
/*     */ import nccloud.bs.pub.pf.CloudPfUtil;
/*     */ import nccloud.commons.lang.StringUtils;
/*     */ import nccloud.pubitf.riart.pflow.CloudPFlowContext;
/*     */ import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService;
/*     */ 
/*     */ public class NCCloudScriptPFlowServiceImpl implements ICloudScriptPFlowService
/*     */ {
/*     */   @Deprecated
/*     */   public Object[] exeScriptPFlow_RequiresNew(CloudPFlowContext context) throws BusinessException
/*     */   {
/*  30 */     return exeScriptPFlow(context);
/*     */   }
/*     */   
/*     */   private Object[] procFlow(CloudPFlowContext context) throws Exception
/*     */   {
/*  35 */     Object[] retObjs = null;
/*  36 */     Object[] noflowretObjs = null;
/*  37 */     if (context.geteParam() == null) {
/*  38 */       Map<Object, Object> eparam = new HashMap();
/*  39 */       eparam.put("NCCLOUD_ENTRY", Boolean.valueOf(true));
/*  40 */       eparam.put("IS_RELOADBILL", Boolean.valueOf(true));
/*     */       
/*  42 */       context.seteParam(eparam);
/*     */     }
/*     */     
/*  45 */     if ((context.geteParam() != null) && (!context.geteParam().containsKey("NCCLOUD_ENTRY")))
/*     */     {
/*  47 */       context.geteParam().put("IS_RELOADBILL", Boolean.valueOf(true));
/*     */       
/*  49 */       context.geteParam().put("NCCLOUD_ENTRY", Boolean.valueOf(true));
/*     */     }
/*     */     
/*  52 */     List nofloiwAggvos = new ArrayList();
/*  53 */     List floiwAggvos = new ArrayList();
/*  54 */     Object resingle = null;
/*     */     
/*     */ 
/*  57 */     boolean isUnsaveAcion = (PfUtilBaseTools.isRecallAction(context.getActionName(), context.getBillType())) || (PfUtilBaseTools.isUnSaveAction(context.getActionName(), context.getBillType()));
/*     */     
/*     */ 
/*  60 */     if (isUnsaveAcion) {
/*  61 */       for (AggregatedValueObject aggvo : context.getBillVos())
/*     */       {
/*  63 */         WorkflowTypeEnum flowtype = PfUtilTools.runningFlowStatus(StringUtils.isNotEmpty(context.getTrantype()) ? context
/*  64 */           .getTrantype() : context
/*  65 */           .getBillType(), aggvo.getParentVO().getPrimaryKey());
/*  66 */         if (flowtype == null) {
/*  67 */           nofloiwAggvos.add(aggvo);
/*     */         } else {
/*  69 */           floiwAggvos.add(aggvo);
/*     */         }
/*     */       }
/*     */       
/*  73 */       if (nofloiwAggvos.size() > 0) {
/*  74 */         noflowretObjs = CloudPfUtil.runScriptPFlow_UnSaveNoFlowBatch(context.getActionName(), context
/*  75 */           .getTrantype() == null ? context.getBillType() : context.getTrantype(), 
/*  76 */           (AggregatedValueObject[])nofloiwAggvos.toArray(new AggregatedValueObject[0]), context
/*  77 */           .getBatchUserObj(), null, context
/*  78 */           .geteParam() == null ? null : (HashMap)context.geteParam());
/*     */         
/*  80 */         if ((nofloiwAggvos.size() == 1) && (noflowretObjs != null) && (floiwAggvos.size() == 0) && 
/*  81 */           ((noflowretObjs[0] instanceof PfProcessBatchRetObject))) {
/*  82 */           PfProcessBatchRetObject reresult = (PfProcessBatchRetObject)noflowretObjs[0];
/*     */           
/*  84 */           if (StringUtils.isEmpty(reresult.getExceptionInfo().getErrorMessage())) {
/*  85 */             return reresult.getRetObj();
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  97 */     if ((floiwAggvos.size() > 0) && (isUnsaveAcion)) {
/*  98 */       context.setBillVos((AggregatedValueObject[])floiwAggvos.toArray(new AggregatedValueObject[0]));
/*     */     }
/*     */     
/*     */ 
/* 102 */     if (((floiwAggvos.size() > 0) && (isUnsaveAcion)) || (
/* 103 */       (context.getBillVos() != null) && (context.getBillVos().length >= 1) && (!isUnsaveAcion))) {
/* 104 */       if ((context.getBillVos() != null) && (context.getBillVos().length > 1)) {
/* 105 */         retObjs = CloudPfUtil.runBatch(context.getActionName(), context
/* 106 */           .getTrantype() == null ? context.getBillType() : context.getTrantype(), context
/* 107 */           .getBillVos(), context.getBatchUserObj(), null, context
/* 108 */           .geteParam() == null ? null : (HashMap)context.geteParam());
/* 109 */       } else if ((context.getBillVos() != null) && (context.getBillVos().length == 1)) {
/* 110 */         Object retObj = CloudPfUtil.runAction(context.getActionName(), context
/* 111 */           .getTrantype() == null ? context.getBillType() : context.getTrantype(), context
/* 112 */           .getBillVos()[0], context
/* 113 */           .getUserObj() == null ? null : context.getUserObj()[0].getUserObject(), null, null, context
/* 114 */           .geteParam() == null ? null : (HashMap)context.geteParam());
/*     */         
/* 116 */         if ((retObj instanceof Object[])) {
/* 117 */           retObjs = (Object[])retObj;
/*     */         } else {
/* 119 */           retObjs = new Object[] { retObj };
/*     */         }
/*     */       }
/*     */     }
/* 123 */     if (noflowretObjs != null) {
/* 124 */       if (retObjs != null) {
/* 125 */         Object noflowlist = new ArrayList(Arrays.asList(noflowretObjs));
/* 126 */         ((List)noflowlist).addAll(Arrays.asList(retObjs));
/* 127 */         return ((List)noflowlist).toArray();
/*     */       }
/* 129 */       return noflowretObjs;
/*     */     }
/*     */     
/* 132 */     return retObjs;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Object[] exeScriptPFlow(CloudPFlowContext context)
/*     */     throws BusinessException
/*     */   {
	Object[] ret;
/*     */     try
/*     */     {
/* 147 */       ret = procFlow(context);
/*     */     } catch (Exception e) { 
/* 149 */       if ((e instanceof BusinessException)) {
/* 150 */         throw ((BusinessException)e);
/*     */       }
/* 152 */       throw new BusinessRuntimeException(e.getMessage(), e);
/*     */     }
/* 155 */     return ret;
/*     */   }
/*     */   
/*     */   public Object[] exeScriptPFlow_CommitNoFlowBatch(CloudPFlowContext context) throws BusinessException
/*     */   {
/* 160 */     Object[] retObjs = null;
/*     */     try {
/* 162 */       if ((context.getBillVos() != null) && (context.getBillVos().length >= 1)) {
/* 163 */         retObjs = CloudPfUtil.runScriptPFlow_CommitNoFlowBatch(context.getActionName(), context
/* 164 */           .getTrantype() == null ? context.getBillType() : context.getTrantype(), context
/* 165 */           .getBillVos(), context.getBatchUserObj(), null, context
/* 166 */           .geteParam() == null ? null : (HashMap)context.geteParam());
/*     */       } else {
/* 168 */         throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1501002_0", "01501002-0323"));
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 172 */       throw new BusinessRuntimeException(e.getMessage(), e);
/*     */     }
/* 174 */     return retObjs;
/*     */   }
/*     */   
/*     */   public Object[] exeScriptPFlow_UnSaveNoFlowBatch(CloudPFlowContext context) throws BusinessException
/*     */   {
/* 179 */     Object[] retObjs = null;
/*     */     try {
/* 181 */       if ((context.getBillVos() != null) && (context.getBillVos().length >= 1)) {
/* 182 */         retObjs = CloudPfUtil.runScriptPFlow_UnSaveNoFlowBatch(context.getActionName(), context
/* 183 */           .getTrantype() == null ? context.getBillType() : context.getTrantype(), context
/* 184 */           .getBillVos(), context.getBatchUserObj(), null, context
/* 185 */           .geteParam() == null ? null : (HashMap)context.geteParam());
/*     */       } else {
/* 187 */         throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1501002_0", "01501002-0323"));
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 191 */       throw new BusinessRuntimeException(e.getMessage(), e);
/*     */     }
/* 193 */     return retObjs;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Object[] exeScriptPFlow_CommitNoFlowBatchNew(CloudPFlowContext context)
/*     */     throws BusinessException
/*     */   {
/* 201 */     Object[] retObjs = null;
/*     */     try {
/* 203 */       if ((context.getBillVos() != null) && (context.getBillVos().length >= 1)) {
/* 204 */         retObjs = CloudPfUtil.runScriptPFlow_CommitNoFlowBatchNew(context.getActionName(), context
/* 205 */           .getTrantype() == null ? context.getBillType() : context.getTrantype(), context
/* 206 */           .getBillVos(), context.getBatchUserObj(), null, context
/* 207 */           .geteParam() == null ? null : (HashMap)context.geteParam());
/*     */       } else {
/* 209 */         throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1501002_0", "01501002-0323"));
/*     */       }
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 214 */       throw new BusinessRuntimeException(e.getMessage(), e);
/*     */     }
/* 216 */     return retObjs;
/*     */   }
/*     */ }

/* Location:           C:\ncc\ncchome2105\modules\riawf\META-INF\lib\riawf_riawfplatform_rtLevel-1.jar
 * Qualified Name:     nccloud.pubimpl.riart.pflow.NCCloudScriptPFlowServiceImpl
 * Java Class Version: 8 (52.0)
 * JD-Core Version:    0.7.1
 */